package gui;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.util.Random;

/**
 *
 * @author Alexis
 */
public class Obstacle extends ElementDuJeu {

    int positionX, positionY, width, height, type;
    Shape forme;
    Color couleur;
    Area area;
    Random rand;
    Monde monde;
    int fub;
    
    public Obstacle(Monde monde, int positionX, int positionY, int width, int height,int type) {
        this.monde = monde;
        
        rand=new Random();
        this.positionX = positionX;
        this.positionY = positionY;
        this.width = width;
        this.height = height;
        this.type=type;
        this.setLocation(positionX, positionY);
        this.setSize(width, height);
        switch (type) {
            case 0:{
                forme = new Rectangle2D.Float(0, 0, width, height);
                area = new Area(new Rectangle2D.Float(positionX, positionY, width, height)); 
            }
                break;
            case 1: {
                forme = new Ellipse2D.Float(0, 0, width, height);
                area = new Area(new Ellipse2D.Float(positionX, positionY, width, height)); }
                break;
        }
               
        couleur = new Color(rand.nextInt(255), rand.nextInt(255), rand.nextInt(255));
        
    }
    
    @Override
    public void paintComponent(Graphics g) {
        Graphics2D g2d = (Graphics2D) g;
        g2d.setColor(couleur);
        g2d.fill(forme);
        g2d.setStroke(new BasicStroke(5));
        g2d.setColor(Color.BLACK);        
        g2d.draw(forme);
         
    }

    public Area getArea() {
        return area;
    }
    
}
